/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ep.m005.ui.controllers;

import com.vaadin.data.util.BeanItemContainer;
import ep.m005.bl.BL005Controller;
import ep.persistence.controllers.T009MedicineJpaController;
import ep.persistence.entities.T009Medicine;
import java.util.Collection;
import javax.persistence.Query;

/**
 *
 * @author Spyros
 */
public class SelectMedicineController {

    private BL005Controller bL005Controller;

    public SelectMedicineController() {
        bL005Controller = new BL005Controller();
    }

    public BeanItemContainer<T009Medicine> getMedicineBySubstance(String subName) {
        Collection c =  bL005Controller.getMedicineBySubstance(subName.trim());
        return new BeanItemContainer<T009Medicine>(T009Medicine.class, c);
    }

    public BeanItemContainer<T009Medicine> getMedicineByMedName(String medName) {
//        T009MedicineJpaController jpaController = new T009MedicineJpaController();
//        Query query = jpaController.getEntityManager().createNamedQuery("T009Medicine.findByName", T009Medicine.class);
//        query.setParameter("name", medName.trim());
//        Collection c = query.getResultList();
        Collection c = bL005Controller.getMedicineByMedName(medName.trim());
        return new BeanItemContainer<T009Medicine>(T009Medicine.class, c);
    }

}
